Micron Document
Livres et Wikis | Archives | Info


JavaScript syntax
part 30/43 Β· 161.3 KB total
layout: Wide Β· Narrow Β· Centered
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
// statements;
break;
case ANOTHERVALUE:
// statements for when ANOTHERVALUE || ORNAOTHERONE
// no break statement, falling through to the following case
case ORANOTHERONE:
// statements specific to ORANOTHERONE (i.e. !ANOTHERVALUE &&
ORANOTHER);
break; //The buck stops here.
case YETANOTHER:
// statements;
break;
default:
// statements;
break;
}

β€’ break; is optional; however, it is usually needed, since otherwise
code execution will continue to the body of the next case block. This
fall through behavior can be used when the same set of statements apply
in several cases, effectively creating a disjunction between those
cases.
β€’ Add a break statement to the end of the last case as a precautionary
measure, in case additional cases are added later.
β€’ String literal values can also be used for the case values.
β€’ Expressions can be used instead of values.
β€’ The default case (optional) is executed when the expression does not
match any other specified cases.
β€’ Braces are required.

For loop

The syntax of the JavaScript for loop is as follows:

for (initial; condition; loop statement) {
/*
statements will be executed every time
the for{} loop cycles, while the
condition is satisfied
*/
}

or

for (initial; condition; loop statement(iteration)) // one statement

For ... in loop

The syntax of the JavaScript for ... in loop is as follows:

for (var property_name in some_object) {
// statements using some_object[property_name];
}

β€’ Iterates through all enumerable properties of an object.
β€’ Iterates through all used indices of array including all user-defined
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────